package com.demo.designmode.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: jxm
 * @Description: 具体的容器类
 * @Date: 2023-12-12 14:47
 * @Version: 1.0
 */
public class StudentAggregateImpl implements StudentAggregate{

    private List<Student> list;

    public StudentAggregateImpl() {
        this.list = new ArrayList<>();
    }

    @Override
    public void addStudent(Student student) {
        list.add(student);
    }

    @Override
    public void removeStudent(Student student) {
        list.remove(student);
    }

    @Override
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(list);
    }
}
